<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:a="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich"
    template="layout/template.xhtml">

<ui:define name="body">

    <h:form id="invCompras" styleClass="edit">

        <rich:panel>
            <f:facet name="header">#{invComprasHome.managed ? 'Edit' : 'Add'} Inv compras</f:facet>


            <s:decorate id="cmpCodigoField" template="layout/edit.xhtml">
                <ui:define name="label">Cmp codigo</ui:define>
                <h:inputText id="cmpCodigo"
                       required="true"
                       disabled="#{invComprasHome.managed}"
                          value="#{invComprasHome.instance.cmpCodigo}">
                    <a:support event="onblur" reRender="cmpCodigoField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>


            <s:decorate id="cmpFechaField" template="layout/edit.xhtml">
                <ui:define name="label">Cmp fecha</ui:define>
                <rich:calendar id="cmpFecha"
                          value="#{invComprasHome.instance.cmpFecha}" datePattern="MM/dd/yyyy" />
            </s:decorate>


            <s:decorate id="cmpGrabadoField" template="layout/edit.xhtml">
                <ui:define name="label">Cmp grabado</ui:define>
                <h:inputText id="cmpGrabado"
                          value="#{invComprasHome.instance.cmpGrabado}">
                    <a:support event="onblur" reRender="cmpGrabadoField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>


            <s:decorate id="depCodigoField" template="layout/edit.xhtml">
                <ui:define name="label">Dep codigo</ui:define>
                <h:inputText id="depCodigo"
                          value="#{invComprasHome.instance.depCodigo}">
                    <a:support event="onblur" reRender="depCodigoField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>



            <div style="clear:both">
                <span class="required">*</span>
                required fields
            </div>

        </rich:panel>

        <div class="actionButtons">

            <h:commandButton id="save"
                          value="Save"
                         action="#{invComprasHome.persist}"
                       disabled="#{!invComprasHome.wired}"
                       rendered="#{!invComprasHome.managed}"/>

            <h:commandButton id="update"
                          value="Save"
                         action="#{invComprasHome.update}"
                       rendered="#{invComprasHome.managed}"/>

            <h:commandButton id="delete"
                          value="Delete"
                         action="#{invComprasHome.remove}"
                      immediate="true"
                       rendered="#{invComprasHome.managed}"/>

            <s:button id="cancelEdit"
                   value="Cancel"
             propagation="end"
                    view="/InvCompras.xhtml"
                rendered="#{invComprasHome.managed}"/>

            <s:button id="cancelAdd"
                   value="Cancel"
             propagation="end"
                    view="/#{empty invComprasFrom ? 'InvComprasList' : invComprasFrom}.xhtml"
                rendered="#{!invComprasHome.managed}"/>

        </div>
    </h:form>

<rich:tabPanel switchType="ajax">

    <rich:tab label="Inv detalles">
        <h:form styleClass="association" id="invDetallesChildren">

            <h:outputText value="There are no invDetalles associated with this invCompras."
                       rendered="#{empty invComprasHome.invDetalles}"/>

            <rich:dataTable value="#{invComprasHome.invDetalles}"
                           var="_invDetalle"
                      rendered="#{not empty invComprasHome.invDetalles}"
                    rowClasses="rvgRowOne,rvgRowTwo"
                            id="invDetallesTable">
                <rich:column sortBy="#{_invDetalle.detCodItem}">
                    <f:facet name="header">Det cod item</f:facet>
                    <h:outputText value="#{_invDetalle.detCodItem}"/>
                </rich:column>
                <rich:column sortBy="#{_invDetalle.depCodigo}">
                    <f:facet name="header">Dep codigo</f:facet>
                    <h:outputText value="#{_invDetalle.depCodigo}"/>
                </rich:column>
                <rich:column sortBy="#{_invDetalle.detCodGrupo}">
                    <f:facet name="header">Det cod grupo</f:facet>
                    <h:outputText value="#{_invDetalle.detCodGrupo}"/>
                </rich:column>
                <rich:column sortBy="#{_invDetalle.detCosto}">
                    <f:facet name="header">Det costo</f:facet>
                    <h:outputText value="#{_invDetalle.detCosto}">
                        <f:convertNumber/>
                    </h:outputText>
                </rich:column>
                <rich:column sortBy="#{_invDetalle.detPrecioConfirm}">
                    <f:facet name="header">Det precio confirm</f:facet>
                    <h:outputText value="#{_invDetalle.detPrecioConfirm}">
                        <f:convertNumber/>
                    </h:outputText>
                </rich:column>
                <rich:column sortBy="#{_invDetalle.detPrecioSugerid}">
                    <f:facet name="header">Det precio sugerid</f:facet>
                    <h:outputText value="#{_invDetalle.detPrecioSugerid}">
                        <f:convertNumber/>
                    </h:outputText>
                </rich:column>
                <rich:column sortBy="#{_invDetalle.subdepCodigo}">
                    <f:facet name="header">Subdep codigo</f:facet>
                    <h:outputText value="#{_invDetalle.subdepCodigo}"/>
                </rich:column>
            </rich:dataTable>

        </h:form>

        <f:subview rendered="#{invComprasHome.managed}" id="invDetalles">
        <div class="actionButtons">
            <s:button id="addinvDetalle"
                   value="Add invDetalle"
                    view="/InvDetalleEdit.xhtml"
             propagation="none">
                 <f:param name="invComprasCmpCodigo"
                         value="#{invComprasHome.instance.cmpCodigo}"/>
                 <f:param name="invDetalleFrom" value="InvCompras"/>
            </s:button>
        </div>
        </f:subview>
    </rich:tab>

    <rich:tab label="Subdepartamento">
    <div class="association" id="subdepartamentoParent">

        <h:outputText value="There is no subdepartamento associated with this invCompras."
                   rendered="#{invComprasHome.instance.subdepartamento == null}"/>

        <rich:dataTable var="_subdepartamento"
                   value="#{invComprasHome.instance.subdepartamento}"
                rendered="#{invComprasHome.instance.subdepartamento != null}"
              rowClasses="rvgRowOne,rvgRowTwo"
                      id="subdepartamentoTable">
            <h:column>
                <f:facet name="header">Subdep codigo</f:facet>
                <h:outputText value="#{_subdepartamento.subdepCodigo}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Departamento dep codigo</f:facet>
                <h:outputText value="#{_subdepartamento.departamento.depCodigo}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Descripcion</f:facet>
                <h:outputText value="#{_subdepartamento.descripcion}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Encargado</f:facet>
                <h:outputText value="#{_subdepartamento.encargado}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Telefono</f:facet>
                <h:outputText value="#{_subdepartamento.telefono}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Usuario usu codigo</f:facet>
                <h:outputText value="#{_subdepartamento.usuario.usuCodigo}"/>
            </h:column>
        </rich:dataTable>

        <div class="actionButtons">
            <s:button value="#{invComprasHome.instance.subdepartamento != null ? 'Change' : 'Select'} subdepartamento"
                       view="/SubdepartamentoList.xhtml">
                <f:param name="from" value="InvComprasEdit"/>
            </s:button>
        </div>

    </div>
    </rich:tab>
</rich:tabPanel>
</ui:define>

</ui:composition>
